package cn.edu.dz.mmcock;

public class Child extends  Thread {

    private  Kitchen kitchen;
    //体力值
    private  int hp=0;
    //健康值
    private int health;

    public Child( String name, Kitchen kitchen,int health) {
        super( name);
        this.kitchen = kitchen;
        this.health = health;
    }

    public void  eat()throws InterruptedException{
        this.kitchen.do_eat();
    }

    @Override
    public void run() {

        while(this.hp<this.health){
            try{
                this.eat();
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            System.out.println(this.getName()+"我吃饱了，谢谢妈妈。。。。");
        }
    }

    public Kitchen getKitchen() {
        return kitchen;
    }

    public void setKitchen(Kitchen kitchen) {
        this.kitchen = kitchen;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        this.health = health;
    }
}
